<template>
  <div>
    <ArticleItem v-for="(article, i) in articles" :key="i" :article="article"
                 @click_likeArticle="click_likeArticle"></ArticleItem>
  </div>
</template>

<script>
  import ArticleItem from "../../../components/ArticleItem";

  export default {
    props: ["userId"],
    components: {
      ArticleItem
    },
    data() {
      return {
        articles: []
      }
    },
    mounted() {
      this.getUserLikeArticles()
    },
    methods: {
      async getUserLikeArticles() {
        console.log(this.userId)
        let res = await this.$http.get("/user/" + this.userId + "/likeArticles")
        if (res.code == 0) {
          this.articles = res.data;
          console.log("articles", this.articles)
        }
      },
      click_likeArticle() {
        this.getUserLikeArticles()
      }
    }
  }
</script>

<style scoped>

</style>
